package cn.donting.jme.editor.scene;

import com.jme3.export.*;

import java.io.IOException;

public abstract class Wrapper<T extends Savable> implements Savable {
    private T value;

    public Wrapper(T value) {
        this.value = value;
    }

    public Wrapper() {
    }

    public T getValue() {
        return value;
    }

    public void initValue(T value){
        this.value=value;
    }

    @Override
    public void write(JmeExporter ex) throws IOException {
        OutputCapsule capsule = ex.getCapsule(this);
        capsule.write(value, "value", null);

    }

    @Override
    public void read(JmeImporter im) throws IOException {
        InputCapsule capsule = im.getCapsule(this);
        value = (T) capsule.readSavable("value", null);
    }
}
